package com.bzy.blade_auth.service.impl;

import com.baomidou.mybatisplus.extension.api.R;
import com.bzy.blade_auth.config.util.ParmUtil;
import com.bzy.blade_auth.mapper.RoleMapper;
import com.bzy.blade_auth.service.RoleService;
import com.bzy.bladeauthapi.entry.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoleServiceImpl implements RoleService {


    @Autowired
    private RoleMapper roleMapper;

    @Override
    public R add(Role role) {
        roleMapper.insert(role);
        return R.ok(role);
    }

    @Override
    public R uodate(Role role) {
        String parmId = ParmUtil.parameterIntended(role, "id");
        if(parmId!=null){
            return R.failed(parmId);
        }
        roleMapper.updateById(role);
        return R.ok(role);
    }

    @Override
    public R delete(Role role) {
        String parmId = ParmUtil.parameterIntended(role, "id");
        if(parmId!=null){
            return R.failed(parmId);
        }
        roleMapper.deleteById(role.getId());
        return null;
    }

    @Override
    public R selOne(Role role) {
        return R.ok( roleMapper.selOne(role));
    }

    @Override
    public R selList(Role role) {
        return R.ok(role);
    }
}












